//
//  MYY_MessageCell.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/10/26.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "MYY_MessageCell.h"
#import "YMTabBarButton.h"
#import "MYY_MessageMarco.h"
#import "MYYMessageModel.h"
#import "MYY_Me_Macro.h"


@interface MYY_MessageCell()

@property(nonatomic, strong) UIView *hengLine;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIImageView *YMTabBarButto;
@property(nonatomic, strong) YMTabBarButton *YMTabBarBu;
@property(nonatomic, strong) UIImage *iameg;
@property(nonatomic, strong) UILabel *contentLable;
@property(nonatomic,strong)UILabel *createTimeLabel;
@end
@implementation MYY_MessageCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"MYY_MessageCell";
    MYY_MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[MYY_MessageCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.selectionStyle          = UITableViewCellSelectionStyleNone;
        cell.backgroundColor         = [UIColor whiteColor];
    }
    
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initCreatUI];
        
    }
    return self;
}

-(void)initCreatUI
{
    
    [self addSubview:self.YMTabBarButto];
    [self addSubview:self.titleLabel];
    [self addSubview:self.hengLine];
    [self addSubview:self.YMTabBarBu];
    [self addSubview:self.createTimeLabel];
    [self addSubview:self.contentLable];
    [_YMTabBarButto mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(20);
        make.centerY.equalTo(self);
        make.height.mas_equalTo(MYY_Message_CELL_thum_H);
        make.width.mas_equalTo(MYY_Message_CELL_thum_H);
        
    }];
    [_YMTabBarBu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(20);
        make.centerY.equalTo(self);
        make.height.mas_equalTo(MYY_Message_CELL_thum_H);
        make.width.mas_equalTo(MYY_Message_CELL_thum_H);
        
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.YMTabBarButto.mas_right).with.offset(10);
        make.top.equalTo(_YMTabBarButto);
    }];
   
    [self.contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLabel);
        // make.right.equalTo(self.indicatorView.mas_left).with.offset(-12);
        make.top.equalTo(_titleLabel.mas_bottom).mas_offset(5);
    }];
    [_createTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_top);
        make.right.equalTo(self).with.offset(-10);
        make.height.mas_equalTo(_titleLabel);
    }];

    [_hengLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.YMTabBarButto.mas_right).with.offset(10);
        make.bottom.right.equalTo(self);
        make.height.equalTo(@0.5);
    }];
    
    
}
- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = MYYFont(14.0f);
        _titleLabel.numberOfLines = 1;
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.textColor = MYYtitleColor;
        _titleLabel.text = @"飞飞";
    }
    return _titleLabel;
}

- (UIView *)hengLine
{
    if (_hengLine == nil) {
        _hengLine = [[UIView alloc] init];
        _hengLine.backgroundColor =MYYlineColor;
    }
    return _hengLine;
}


- (UIImageView *)YMTabBarButto
{
    if (_YMTabBarButto == nil) {
        _YMTabBarButto = [[UIImageView alloc] init];
        _YMTabBarButto.clipsToBounds = YES;
        _YMTabBarButto.layer.cornerRadius =MYY_Message_CELL_thum_H/2;
        //        _YMTabBarButto.item = [[UITabBarItem alloc] initWithTitle:nil
        //                                                        image:[UIImage imageNamed:@"qianyue"]
        //                                                selectedImage:nil];
    }
    return _YMTabBarButto;
}
- (YMTabBarButton *)YMTabBarBu
{
    if (_YMTabBarBu == nil) {
        _YMTabBarBu = [[YMTabBarButton alloc] init];
        _YMTabBarBu.item = [[UITabBarItem alloc] initWithTitle:nil
                                                         image:[UIImage imageNamed:@" "]
                                                 selectedImage:nil];
    }
    return _YMTabBarBu;
}
- (UILabel *)createTimeLabel
{
    if (_createTimeLabel == nil) {
        _createTimeLabel = [[UILabel alloc] init];
        _createTimeLabel.font = MYYFont(12.0f);
        _createTimeLabel.numberOfLines = 1;
        _createTimeLabel.textAlignment = NSTextAlignmentRight;
        _createTimeLabel.textColor = MYYcontenColor;
        
    }
    return _createTimeLabel;
}
- (UILabel *)contentLable
{
    if (_contentLable == nil) {
        _contentLable = [UILabel new];
        _contentLable.backgroundColor = [UIColor clearColor];
        _contentLable.numberOfLines = 1;
        _contentLable.textColor = MYYcontenColor;
        _contentLable.font = MYYFont(12.0);
        _contentLable.text = @"飞飞";
    }
    return _contentLable;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)setMYYMessageMode:(MYYMessageModel *)MYYMessageMode{
    _MYYMessageMode = MYYMessageMode;
   _YMTabBarButto.image =[UIImage imageNamed:_MYYMessageMode.thum];
   _YMTabBarBu.item.badgeValue             = _MYYMessageMode.anew;
   _contentLable.text =_MYYMessageMode.content;
   _titleLabel.text =_MYYMessageMode.title;
   _createTimeLabel.text =_MYYMessageMode.createTime;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
